﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebUtils;

namespace OAuth.ServiceProviders
{
    public class OAuthSandbox : DefaultOAuthServiceProvider
    {
        private const string REQUEST_URL = "http://oauth-sandbox.mediamatic.nl/module/OAuth/request_token";
        private const string ACCESS_URL = "http://oauth-sandbox.mediamatic.nl/module/OAuth/access_token";
        private const string USER_AUTH_URL = "http://oauth-sandbox.mediamatic.nl/module/OAuth/authorize";

        readonly private Action<string> completeUrlUserAuthHandler;
        
        public OAuthSandbox(Action<string> pCompleteUrlUserAuthHandler) : base(REQUEST_URL, ACCESS_URL)
        {
            completeUrlUserAuthHandler = pCompleteUrlUserAuthHandler;
        }

        public override void WithRequestTokenResult( string pRequestToken, string pRequestTokenSecret, IEnumerable<UnEncodedURLParameter> pAdditionalParameters )
        {
            var completeUrl = string.Format("{0}?oauth_token={1}", USER_AUTH_URL, pRequestToken);
            completeUrlUserAuthHandler(completeUrl);
        }
    }
}
